package com.zmc.order.controller;

import com.zmc.common.utils.R;
import com.zmc.order.application.CommentApplicationService;
import com.zmc.order.infrastructure.bean.query.CommentInfoQuery;
import com.zmc.order.infrastructure.bean.query.GoodDetailCommentQuery;
import com.zmc.order.infrastructure.bean.vo.CommentInfoVo;
import com.zmc.order.infrastructure.service.CommentInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：zmc
 * @Date：2025/2/20 17:52
 * 评论列表
 */
@RestController
@RequestMapping("/comment")
public class CommentController {


    @Autowired
    private CommentInfoService commentInfoService;

    @Autowired
    private CommentApplicationService commentApplicationService;

    /**
     * 商家评论列表
     * */
    @PostMapping("/list")
    public R list(@RequestBody CommentInfoQuery query) {
        return R.page(commentInfoService.queryPage(query));
    }

    /**
     * 商品详情页展示评论列表
     * */
    @PostMapping("/good/detail/list")
    public R goodDetailComment(@RequestBody GoodDetailCommentQuery query) {
        return R.ok(commentInfoService.queryGoodDetailCommentPage(query));
    }

    /**
     * 商家回复
     * */
    @RequestMapping("/answer")
    public R answer(@RequestBody CommentInfoVo vo) {
        commentApplicationService.answer(vo);
        return R.ok();
    }

    /**
     * 删除评价
     * */
    @RequestMapping("/delete/{id}")
    public R delete(@PathVariable Long id){
        commentApplicationService.removeComment(id);
        return R.ok();
    }




}
